package com.xjy.web.controller.system.basics;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import javax.validation.constraints.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.xjy.common.annotation.RepeatSubmit;
import com.xjy.common.annotation.Log;
import com.xjy.common.core.controller.BaseController;
import com.xjy.common.core.domain.AjaxResult;
import com.xjy.common.enums.BusinessType;
import com.xjy.system.domain.vo.SysPaycolTypeVo;
import com.xjy.system.domain.bo.SysPaycolTypeQueryBo;
import com.xjy.system.domain.bo.SysPaycolTypeAddBo;
import com.xjy.system.domain.bo.SysPaycolTypeEditBo;
import com.xjy.system.service.ISysPaycolTypeService;
import com.xjy.common.utils.poi.ExcelUtil;
import com.xjy.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 收/付款到期提醒方式信息Controller
 *
 * @author zc
 * @date 2022-02-09
 */
@Api(value = "收/付款到期提醒方式信息控制器", tags = {"收/付款到期提醒方式信息管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/SysPaycolType")
public class SysPaycolTypeController extends BaseController {

    private final ISysPaycolTypeService iSysPaycolTypeService;

    /**
     * 查询收/付款到期提醒方式信息列表
     */
    @ApiOperation("查询收/付款到期提醒方式信息列表")
    @PreAuthorize("@ss.hasPermi('system:SysPaycolType:list')")
    @GetMapping("/list")
    public TableDataInfo<SysPaycolTypeVo> list(@Validated SysPaycolTypeQueryBo bo) {
        return iSysPaycolTypeService.queryPageList(bo);
    }

    /**
     * 导出收/付款到期提醒方式信息列表
     */
    @ApiOperation("导出收/付款到期提醒方式信息列表")
    @PreAuthorize("@ss.hasPermi('system:SysPaycolType:export')")
    @Log(title = "收/付款到期提醒方式信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<SysPaycolTypeVo> export(@Validated SysPaycolTypeQueryBo bo) {
        List<SysPaycolTypeVo> list = iSysPaycolTypeService.queryList(bo);
        ExcelUtil<SysPaycolTypeVo> util = new ExcelUtil<SysPaycolTypeVo>(SysPaycolTypeVo.class);
        return util.exportExcel(list, "收/付款到期提醒方式信息");
    }

    /**
     * 获取收/付款到期提醒方式信息详细信息
     */
    @ApiOperation("获取收/付款到期提醒方式信息详细信息")
    @PreAuthorize("@ss.hasPermi('system:SysPaycolType:query')")
    @GetMapping("/{id}")
    public AjaxResult<SysPaycolTypeVo> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("id") Long id) {
        return AjaxResult.success(iSysPaycolTypeService.queryById(id));
    }

    /**
     * 新增收/付款到期提醒方式信息
     */
    @ApiOperation("新增收/付款到期提醒方式信息")
    @PreAuthorize("@ss.hasPermi('system:SysPaycolType:add')")
    @Log(title = "收/付款到期提醒方式信息", businessType = BusinessType.INSERT)
    @RepeatSubmit
    @PostMapping()
    public AjaxResult<Void> add(@Validated @RequestBody SysPaycolTypeAddBo bo) {
        return toAjax(iSysPaycolTypeService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改收/付款到期提醒方式信息
     */
    @ApiOperation("修改收/付款到期提醒方式信息")
    @PreAuthorize("@ss.hasPermi('system:SysPaycolType:edit')")
    @Log(title = "收/付款到期提醒方式信息", businessType = BusinessType.UPDATE)
    @RepeatSubmit
    @PutMapping()
    public AjaxResult<Void> edit(@Validated @RequestBody SysPaycolTypeEditBo bo) {
        return toAjax(iSysPaycolTypeService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除收/付款到期提醒方式信息
     */
    @ApiOperation("删除收/付款到期提醒方式信息")
    @PreAuthorize("@ss.hasPermi('system:SysPaycolType:remove')")
    @Log(title = "收/付款到期提醒方式信息" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
                                       @PathVariable Long[] ids) {
        return toAjax(iSysPaycolTypeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }
}
